package design_pattern.WorkerThreadMode;

import java.util.Random;

/**
 * @Author: 蔡翔
 * @Date: 2019/11/20 16:05
 * @Version 1.0
 */
public class TransportThread extends Thread{
    private final Channel channel;
    private static final Random random = new Random();

    public TransportThread(String name,Channel channel){
        super(name);
        this.channel = channel;
    }

    @Override
    public void run() {
        try {
            for(int i=0;true;i++){
                Request request = new Request(getName(),i);
                this.channel.put(request);
                Thread.sleep(random.nextInt(1000));
            }
        }catch (Exception e){

        }
    }
}
